<template>
  <div class="donation-page" v-reveal="{ delay: 60 }">
    <div class="container">
      <h1 class="page-title">支持服务器</h1>
      
      <el-row :gutter="40">
        <el-col :xs="24" :lg="16">
          <el-card class="donation-info" v-reveal="{ delay: 120, distance: 20 }">
            <template #header>
              <h2>为什么需要捐赠？</h2>
            </template>
            
            <div class="donation-reasons">
              <el-row :gutter="20">
                <el-col :xs="24" :sm="12" v-for="(reason, idx) in donationReasons" :key="reason.id">
                  <div class="reason-item" v-reveal="{ delay: 160 + idx * 70, distance: 16 }">
                    <div class="reason-icon">
                      <el-icon :size="30" color="#4CAF50">
                        <component :is="reason.icon" />
                      </el-icon>
                    </div>
                    <div class="reason-content">
                      <h3>{{ reason.title }}</h3>
                      <p>{{ reason.description }}</p>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
            
            <div class="donation-benefits">
              <h3>捐赠者福利</h3>
              <el-row :gutter="20">
                <el-col :xs="24" :sm="12" v-for="(benefit, idx) in donationBenefits" :key="benefit.id">
                  <div class="benefit-item" v-reveal="{ delay: 160 + idx * 60, distance: 10 }">
                    <el-icon :size="20" color="#4CAF50" style="margin-right: 8px;">
                      <Check />
                    </el-icon>
                    <span>{{ benefit }}</span>
                  </div>
                </el-col>
              </el-row>
            </div>
          </el-card>
        </el-col>
        
        <el-col :xs="24" :lg="8">
          <el-card class="donation-card" v-reveal="{ delay: 160, distance: 20 }">
            <template #header>
              <h2>立即捐赠</h2>
            </template>
            
            <div class="donation-options">
              <div class="donation-amounts">
                <h3>选择捐赠金额</h3>
                <el-radio-group v-model="selectedAmount" @change="handleAmountChange">
                  <el-row :gutter="10">
                    <el-col :span="12" v-for="(amount, idx) in donationAmounts" :key="amount">
                      <el-radio-button :label="amount" class="amount-button" v-reveal="{ delay: 200 + idx * 50, distance: 8 }">
                        ¥{{ amount }}
                      </el-radio-button>
                    </el-col>
                  </el-row>
                </el-radio-group>
                
                <div class="custom-amount">
                  <el-input
                    v-model="customAmount"
                    placeholder="自定义金额"
                    type="number"
                    @input="handleCustomAmount"
                    v-reveal="{ delay: 240, distance: 8 }"
                  >
                    <template #prepend>¥</template>
                  </el-input>
                </div>
              </div>
              
              <div class="donation-message">
                <h3>留言（可选）</h3>
                <el-input
                  v-model="donationMessage"
                  type="textarea"
                  :rows="3"
                  placeholder="留下您的祝福或建议..."
                  maxlength="100"
                  show-word-limit
                  v-reveal="{ delay: 260, distance: 8 }"
                />
              </div>
              
              <div class="payment-method">
                <h3>支付方式</h3>
                <div class="qr-code">
                  <img src="@/assets/images/wechat-qr.png" alt="微信支付" v-reveal="{ delay: 280, distance: 8 }" />
                  <p>微信扫码支付</p>
                </div>
              </div>
              
              <el-button 
                type="primary" 
                size="large" 
                @click="handleDonation"
                style="width: 100%; margin-top: 20px;"
                v-reveal="{ delay: 300, distance: 8 }"
              >
                确认捐赠
              </el-button>
            </div>
          </el-card>
        </el-col>
      </el-row>
      
      <div class="donation-stats" v-reveal="{ delay: 120 }">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="8" v-for="(stat, idx) in donationStats" :key="stat.id">
            <el-card class="stat-card" shadow="hover" v-reveal="{ delay: 160 + idx * 80, distance: 12 }">
              <div class="stat-content">
                <div class="stat-icon">
                  <el-icon :size="40" :color="stat.color">
                    <component :is="stat.icon" />
                  </el-icon>
                </div>
                <div class="stat-info">
                  <h3>{{ stat.value }}</h3>
                  <p>{{ stat.label }}</p>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { 
   
  
  Tools, 
   
  
  DataAnalysis,
  Check,
  Money,
  User,
  Calendar
} from '@element-plus/icons-vue'

export default {
  name: 'DonationPage',
  components: {
    
    Tools,
    
    DataAnalysis,
    Check,
    Money,
    User,
    Calendar
  },
  setup() {
    const selectedAmount = ref(50)
    const customAmount = ref('')
    const donationMessage = ref('')
    
    const donationAmounts = [10, 20, 50, 100, 200, 500]
    
    const donationReasons = ref([
      {
        id: 1,
        title: '服务器硬件升级',
        description: '提升服务器性能，减少卡顿，提供更好的游戏体验',
        icon: 'Server'
      },
      {
        id: 2,
        title: '带宽和网络优化',
        description: '优化网络连接，降低延迟，提高游戏流畅度',
        icon: 'Network'
      },
      {
        id: 3,
        title: '新功能和插件开发',
        description: '开发更多有趣的功能和插件，丰富游戏内容',
        icon: 'Tools'
      },
      {
        id: 4,
        title: '服务器稳定性提升',
        description: '提高服务器稳定性，减少掉线和数据丢失',
        icon: 'Shield'
      },
      {
        id: 5,
        title: '社区活动支持',
        description: '举办各种社区活动，增强玩家互动',
        icon: 'Users'
      },
      {
        id: 6,
        title: '数据备份与安全',
        description: '定期备份数据，保护玩家游戏进度',
        icon: 'DataAnalysis'
      }
    ])
    
    const donationBenefits = ref([
      '专属捐赠者称号',
      '优先进入服务器',
      '特殊聊天颜色',
      '更多传送点',
      '专属皮肤',
      'VIP聊天频道',
      '优先客服支持',
      '活动优先参与'
    ])
    
    const donationStats = ref([
      {
        id: 1,
        label: '累计捐赠金额',
        value: '¥12,580',
        icon: 'Money',
        color: '#4CAF50'
      },
      {
        id: 2,
        label: '捐赠者数量',
        value: '156',
        icon: 'User',
        color: '#2196F3'
      },
      {
        id: 3,
        label: '服务器运行时间',
        value: '365天',
        icon: 'Calendar',
        color: '#FF9800'
      }
    ])

    const handleAmountChange = (value) => {
      customAmount.value = ''
    }

    const handleCustomAmount = () => {
      if (customAmount.value) {
        selectedAmount.value = null
      }
    }

    const handleDonation = () => {
      const amount = customAmount.value || selectedAmount.value
      if (!amount || amount <= 0) {
        ElMessage.warning('请选择或输入捐赠金额')
        return
      }
      
      ElMessage.success(`感谢您的捐赠！金额：¥${amount}`)
      // 这里可以添加实际的支付逻辑
    }

    return {
      selectedAmount,
      customAmount,
      donationMessage,
      donationAmounts,
      donationReasons,
      donationBenefits,
      donationStats,
      handleAmountChange,
      handleCustomAmount,
      handleDonation
    }
  }
}
</script>

<style scoped>
.donation-page {
  padding: 20px 0;
}

.page-title {
  font-size: 2.5rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 40px;
  color: #4CAF50;
}

.donation-info {
  margin-bottom: 30px;
}

.donation-info h2 {
  color: #4CAF50;
  margin: 0;
}

.donation-reasons {
  margin-bottom: 30px;
}

.reason-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 8px;
}

.reason-icon {
  flex-shrink: 0;
}

.reason-content h3 {
  color: #4CAF50;
  margin: 0 0 8px 0;
  font-size: 1.1rem;
}

.reason-content p {
  color: #666;
  margin: 0;
  line-height: 1.6;
}

.donation-benefits h3 {
  color: #4CAF50;
  margin-bottom: 15px;
}

.benefit-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.donation-card h2 {
  color: #4CAF50;
  margin: 0;
}

.donation-options h3 {
  color: #333;
  margin-bottom: 15px;
}

.donation-amounts {
  margin-bottom: 25px;
}

.amount-button {
  width: 100%;
  margin-bottom: 10px;
}

.custom-amount {
  margin-top: 15px;
}

.donation-message {
  margin-bottom: 25px;
}

.payment-method {
  text-align: center;
}

.qr-code {
  margin-top: 15px;
}

.qr-code img {
  width: 200px;
  height: 200px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.qr-code p {
  margin-top: 10px;
  color: #666;
}

.donation-stats {
  margin-top: 40px;
}

.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.stat-info h3 {
  font-size: 1.8rem;
  color: #4CAF50;
  margin: 0;
}

.stat-info p {
  color: #666;
  margin: 5px 0 0 0;
}

@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
  
  .reason-item {
    flex-direction: column;
    text-align: center;
  }
  
  .stat-content {
    flex-direction: column;
    gap: 10px;
  }
  
  .stat-info h3 {
    font-size: 1.5rem;
  }
  
  .qr-code img {
    width: 150px;
    height: 150px;
  }
}
</style> 